package cn.maxwell.openfeign;

import cn.maxwell.domain.Product;
import cn.maxwell.util.JsonResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class StoreProductFeign implements FallbackFactory<OPenFeignInterface> {
    @Override
    public OPenFeignInterface create(Throwable throwable) {
        return new OPenFeignInterface() {
            @Override
            public Product loadById(Long id) {
                return new Product(-1L,"我被熔断了",null);
            }

            @Override
            public JsonResult add(Product product) {
                return new JsonResult(true,"我被熔断了！请稍后再试！！！");
            }
        };
    }
}
